import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
import { getWeekMonthQuarterYear } from '/@/utils';
//列表数据
export const columns: BasicColumn[] = [
   {
    title: '一级菜单名称',
    align:"center",
    dataIndex: 'menuName_dictText'
   },
   {
    title: '分类字典代码',
    align:"center",
    dataIndex: 'menuCode'
   },
   {
    title: '排序',
    align:"center",
    dataIndex: 'orderNum'
   },
   {
    title: '请求路径',
    align:"center",
    dataIndex: 'url'
   },
   {
    title: '发布状态',
    align:"center",
    dataIndex: 'publishStatus_dictText'
   },
   {
    title: '发布人',
    align:"center",
    dataIndex: 'createBy'
   },
   {
    title: '发布时间',
    align:"center",
    dataIndex: 'createTime',
	customRender:({text}) =>{
	  text = !text ? "" : (text.length > 10 ? text.substr(0,10) : text);
	  return text;
	},
   },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
  {
       label:"一级菜单名称",
       field: 'menuName',
       component: 'JDictSelectTag',
       componentProps:{
          dictCode:"web_website_menu"
          //colProps: {span: 6},
      },
  },
  	
    {
        label: "发布状态",
        field: 'publishStatus',
        component: 'JDictSelectTag',
        componentProps:{
            dictCode:"web_publish_status"
        },
        //colProps: {span: 6},
    },
   
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '一级菜单名称',
    field: 'menuName',
    component: 'JDictSelectTag',
    componentProps:{
        dictCode:"web_website_menu"
     },
     dynamicRules: ({model,schema}) => {
       return [
         { required: true, message: '请选择菜单名称!'},
       ];
     },
  },
  {
    label: '分类字典代码',
    field: 'menuCode',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
      return [
        { required: true, message: '请输入分类字典代码!'},
      ];
    },
  },
  {
    label: '排序',
    field: 'orderNum',
    component: 'InputNumber',
  },
  {
    label: '请求路径',
    field: 'url',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
      return [
        { required: true, message: '请输入请求路径!'},
      ];
    },
  },
  {
    label: '发布状态',
    field: 'publishStatus',
    component: 'JDictSelectTag',
    componentProps:{
        dictCode:"web_publish_status"
     },
     dynamicRules: ({model,schema}) => {
       return [
         { required: true, message: '请选择发布状态!'},
       ];
     },
  },
 
	// TODO 主键隐藏字段，目前写死为ID
	{
	  label: '',
	  field: 'id',
	  component: 'Input',
	  show: false
	},
];

// 高级查询数据
export const superQuerySchema = {
  menuName: {title: '一级菜单名称',order: 0,view: 'list', type: 'string',dictCode: 'web_website_menu',},
  menuCode: {title: '分类字典代码',order: 1,view: 'text', type: 'string',},
  orderNum: {title: '排序',order: 2,view: 'number', type: 'number',},
  url: {title: '请求路径',order: 3,view: 'text', type: 'string',},
  publishStatus: {title: '发布状态（0未发布，1已发布，2已撤销）',order: 4,view: 'list', type: 'string',dictCode: 'web_publish_status',},
  publisher: {title: '发布人',order: 5,view: 'text', type: 'string',},
  publishTime: {title: '发布时间',order: 6,view: 'datetime', type: 'string',},
};

/**
* 流程表单调用这个方法获取formSchema
* @param param
*/
export function getBpmFormSchema(_formData): FormSchema[]{
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}
